#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e3+10;
int n,m,L,V,d[N],v[N],a[N],p[N];
int dp[N][N];
bool f[N][N];
void solve(){
    memset(f,0,sizeof(f));
    int ans1=0,ans2=0;
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)
        cin>>d[i]>>v[i]>>a[i];
    for(int i=1;i<=m;i++)
        cin>>p[i];
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(d[j]>p[i]) continue;
            int x=p[i]-d[j];
            if(a[j]<0&&2*a[j]*x+pow(v[j],2)<=0) continue;
            if(pow(v[j],2)+2*a[j]*x>pow(V,2)) f[i][j]=true;
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(f[j][i]){
                ans1++;
                break;
            }
    ans2=rand()%m;
    cout<<ans1<<" "<<ans2<<endl;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
